#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QTextEdit* edit = new QTextEdit(this);
    QTextEdit* copy = new QTextEdit(this);
    edit->resize(300,30);
    copy->resize(300,30);//信号
    copy->move(0, 150);
    QPushButton* button = new QPushButton(this);
    QPushButton* input = new QPushButton(this);
    button->move(0,60);
    input->move(100,60);
    button->setText("输出");
    input->setText("输入");
    connect(button, &QPushButton::clicked, [=](){
        qDebug() << edit->toPlainText().toUtf8().data();
    });
    connect(input,  &QPushButton::clicked, [=]()mutable{
        edit->setTextColor(Qt::red);//ctrl a + i 调整格式
        edit->setTextBackgroundColor(Qt::green);
        edit->setFontPointSize(10);
        edit->setText("这个是自动生成输入的数据");
    });
    connect(edit,&QTextEdit::textChanged, [=](){
        copy->setText(edit->toPlainText());
    });
}

MainWindow::~MainWindow()
{
    delete ui;
}

